package com.kuanter.kuanterauto.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.kuanter.kuanterauto.utils.StringUtils;

public class MessageInfoList {
//	{"status":true,"messageList":[{"content":"大家新年好啊<*^_^*>","id":7,"pushTime":"2013-03-27 15:41:28","title":"新年好"}]}
	private List<MessageInfo> messageInfos=null;
	
	public MessageInfoList(String json){
//		messageInfos=new ArrayList<MessageInfo>();
//		MessageInfo msg=new MessageInfo();
//		msg.setId("7");
//		msg.setContent("大家新年好啊<*^_^*>");
//		msg.setPushTime("2013-03-27 15:41:28");
//		msg.setTitle("新年好");
//		messageInfos.add(msg);
		try {
			if(StringUtils.isSuccess(json)){
				JSONObject jobj=new JSONObject(json);
				JSONArray jarr=jobj.optJSONArray("messageList");
				if(jarr!=null&&jarr.length()>0){
					messageInfos=new ArrayList<MessageInfo>();
					for(int i=0;i<jarr.length();i++){
						JSONObject jo=jarr.optJSONObject(i);
						MessageInfo msg=new MessageInfo();
						msg.setId(jo.optString("id"));
						msg.setContent(jo.optString("content"));
						msg.setPushTime(jo.optString("pushTime"));
						msg.setTitle(jo.optString("title"));
						messageInfos.add(msg);
					}
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public List<MessageInfo> getMessageInfos() {
		return messageInfos;
	}


	
	
}
